﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace PefStudio.Windows
{
    public interface IHasPropertyContainer
    {
        PropertyContainer PropertyContainer { get; }
    }

    public sealed class PropertyContainer
    {
        public PropertyContainer() : this(true) { }

        internal PropertyContainer(bool createPadOnConstruction)
        {
            //if (createPadOnConstruction && WorkbenchSingleton.Workbench != null)
            //{
            //    PadDescriptor desc = WorkbenchSingleton.Workbench.GetPad(typeof(PropertyPad));
            //    if (desc != null) desc.CreatePad();
            //}
        }

        /// <summary>
        /// Gets if this property container is currently shown in the property grid.
        /// </summary>
        public bool IsActivePropertyContainer
        {
            get { return PropertyPad.ActiveContainer == this; }
        }

        object selectedObject;
        object[] selectedObjects;

        public object SelectedObject
        {
            get
            {
                return selectedObject;
            }
            set
            {
                selectedObject = value;
                selectedObjects = null;
                PropertyPad.UpdateSelectedObjectIfActive(this);
            }
        }

        public object[] SelectedObjects
        {
            get
            {
                return selectedObjects;
            }
            set
            {
                selectedObject = null;
                selectedObjects = value;
                PropertyPad.UpdateSelectedObjectIfActive(this);
            }
        }

        ICollection selectableObjects;
        public ICollection SelectableObjects
        {
            get
            {
                return selectableObjects;
            }
            set
            {
                selectableObjects = value;
                PropertyPad.UpdateSelectableIfActive(this);
            }
        }
    }
}
